package net.zjitc.dao.impl;

import net.zjitc.dao.AdminUserDao;
import net.zjitc.pojo.AdminUser;
import net.zjitc.utils.db.C3P0Utils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;

/**
 * Created by 沈银 on 2017/11/18.
 */
public class AdminUserDaoImpl implements AdminUserDao{
    public AdminUser findByCondition(String username, String password) {
        QueryRunner runner=new QueryRunner(C3P0Utils.getDataSource());
        String sql="select * from adminuser where username=? and password=?";
        AdminUser user=null;
        try {
            user= (AdminUser) runner.query(sql,new BeanHandler(AdminUser.class),username,password);
            return user;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
